#define _CRT_SECURE_NO_WARNINGS 
#include <stdio.h>
int main()
{
	int a, b;
	scanf("%d%d", &a, &b);
	int r;
	while ((r = a % b) != 0)
	{
		a = b;
		b = r;
	}
	printf("%d", b);
	return 0;
}